Skip to content

fix: read Header version as a signed Byte at the unparsedBytes gate (JVM parity)#909

Merged
kushti merged 1 commit into
ergoplatform:v0.30.0from
mwaddip:fix/header-version-signed-gate
Jul 9, 2026
Merged

fix: read Header version as a signed Byte at the unparsedBytes gate (JVM parity)#909
kushti merged 1 commit into
ergoplatform:v0.30.0from
mwaddip:fix/header-version-signed-gate

Conversation

@mwaddip

@mwaddip mwaddip commented Jun 15, 2026

Copy link
Copy Markdown

The JVM HeaderWithoutPow reads version as a signed Byte and gates unparsedBytes on version > 1. sigma-rust compared version as u8, so a version byte 0x80 (-128 signed) was read as 128 > 1: the parser consumed unparsedBytes, shifting the AutolykosSolution parse and yielding a different minerPk than the JVM (which skips the region) — a fork vs sigma-state 6.0.3.

Fix: compare the signed value (version as i8) > 1 at the parse and serialize gates. Versions 1/2/3 are positive (signed == unsigned); only version >= 0x80 changes, matching the JVM. Adds a regression test on the 0x80/0x7f witness headers (minerPk infinity vs real point). Validated against the JVM oracle by the conformance suite.

… gate

The JVM `HeaderWithoutPow` reads `version` as a signed `Byte` and gates the
`unparsedBytes` region on `version > 1`. sigma-rust compared `version` as
`u8`, so a version byte 0x80 (-128 signed) was seen as 128 > 1: the parser
consumed `unparsedBytes`, shifting the AutolykosSolution parse and yielding a
different `minerPk` than the JVM (which skips the region) -- a deserialization
fork vs sigma-state 6.0.3.

Compare the signed interpretation `(version as i8) > 1` at the parse and
serialize gates. Versions 1/2/3 are positive, so signed == unsigned; only
version >= 0x80 changes, matching the JVM. The two `version > 1` sites in the
arbitrary proptest generator are left unchanged: it emits only versions {1,2},
and one is a v2-field nulling gate (`!= 1`), not an unparsedBytes gate. Adds a
regression test on the 0x80/0x7f witness headers (minerPk infinity vs real).
@kushti kushti changed the base branch from develop to v0.30.0 July 9, 2026 14:28
@kushti kushti merged commit 15c62d2 into ergoplatform:v0.30.0 Jul 9, 2026
2 of 28 checks passed
@kushti kushti mentioned this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants